package com.snowleopard.findpeople.entity.position;

import java.util.List;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import com.snowleopard.common.base.BaseEntity;
import com.snowleopard.findpeople.entity.publish.InfoPublish;

/**
 * SkeletonArea.
 */
@Entity
@Table(name = "position_area")
public class Area extends BaseEntity {

    private static final long serialVersionUID = 1430305279724038398L;

    private String name;
    private boolean fixed;
    private Set<InfoPublish> infoPublishs;
    private List<Area> children;
    private Area parent;

    @Column(name = "name", length = 50)
    public String getName() {
        return this.name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "area")
    public Set<InfoPublish> getInfoPublishs() {
        return this.infoPublishs;
    }

    public void setInfoPublishs(Set<InfoPublish> infoPublishs) {
        this.infoPublishs = infoPublishs;
    }

    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "parent")
    public List<Area> getChildren() {
        return children;
    }

    public void setChildren(List<Area> children) {
        this.children = children;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "parent_id")
    public Area getParent() {
        return parent;
    }

    public void setParent(Area parent) {
        this.parent = parent;
    }

    @Column(name = "is_fixed")
    public boolean isFixed() {
        return fixed;
    }

    public void setFixed(boolean fixed) {
        this.fixed = fixed;
    }

}
